﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.ParturitionCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ParturitionCommandHandler
{
    public class ParturitionGetCommandHandler : IRequestHandler<ParturitionGetCommand, PageOutput<ParturitionOutput>>
    {
        private readonly IParturitionService _parturitionService;
        public ParturitionGetCommandHandler(IParturitionService parturitionService)
        {
            _parturitionService = parturitionService;
        }
        public async Task<PageOutput<ParturitionOutput>> Handle(ParturitionGetCommand request, CancellationToken cancellationToken)
        {
            var result = await _parturitionService.GetParturition(request.startChildbirthDate, request.endChildbirthDate, request.eartag, request.buildingId, request.toBuildingId, request.broodNumber, request.userId,request.pageIndex,request.pageSize);
            return result;
        }
    }
}
